<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<!-- head 头部-->
<head th:replace="admin/layout/include::head('配置编辑','')"></head>
<body>
<form id="data-form" lay-filter="data-form" class="layui-form model-form">
    <input name="configId" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">配置名</label>
        <div class="layui-input-block">
            <input name="configName" placeholder="请输入配置名" type="text" class="layui-input" maxlength="20"
                   />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">配置编码</label>
        <div class="layui-input-block">
            <input name="configCode" placeholder="请输入配置编码" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">配置域</label>
        <div class="layui-input-block">
            <input name="configType" placeholder="请输入配置域" type="text" class="layui-input" maxlength="20"
                   />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">配置值</label>
        <div class="layui-input-block">
            <textarea name="configValue" placeholder="请输入值" class="layui-textarea" maxlength="200"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="configDesc" placeholder="请输入内容" class="layui-textarea" maxlength="200"></textarea>
        </div>
    </div>
    <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="formSubmit" lay-submit>保存</button>
    </div>
</form>
<!-- js部分 -->
<div th:replace="admin/layout/include::js"></div>
<script>
    layui.use(['layer', 'admin', 'form'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;

        // 回显数据
        var config = admin.getTempData('t_config');
        if (config) {
            form.val('data-form', config);
        }

        // 表单提交事件
        form.on('submit(formSubmit)', function (data) {
            // 表单提交事件
            B.post({
                url: '/admin/config/',
                loading: true,
                data: data.field,
                success: function (data) {
                    if (data.success) {
                        top.layer.msg(data.msg, {icon: 1});
                        admin.putTempData('formOk', true);  // 操作成功刷新表格
                        // 关闭当前iframe弹出层
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    } else {
                        top.layer.msg(data.msg, {icon: 2});
                    }
                }
            });
            return false;
        });

    });
</script>

</body>